package com.ouc.eddyAlgorithm.controller;

import com.ouc.common.annotation.Log;
import com.ouc.common.core.controller.BaseController;
import com.ouc.common.core.domain.AjaxResult;
import com.ouc.common.core.page.TableDataInfo;
import com.ouc.common.enums.BusinessType;
import com.ouc.common.utils.poi.ExcelUtil;
import com.ouc.eddyAlgorithm.domain.SysShip;
import com.ouc.eddyAlgorithm.service.ISysShipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 舰船参数Controller
 *
 * @author yuhao
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/eddyAlgorithm/ship")
public class SysShipController extends BaseController {
  @Autowired
  private ISysShipService sysShipService;

  /**
   * 查询舰船参数列表
   */
  @PreAuthorize("@ss.hasPermi('eddyAlgorithm:ship:list')")
  @GetMapping("/list")
  public TableDataInfo list(SysShip sysShip) {
    startPage();
    List<SysShip> list = sysShipService.selectSysShipList(sysShip);
    return getDataTable(list);
  }

  /**
   * 导出舰船参数列表
   */
  @PreAuthorize("@ss.hasPermi('eddyAlgorithm:ship:export')")
  @Log(title = "舰船参数", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  public void export(HttpServletResponse response, SysShip sysShip) {
    List<SysShip> list = sysShipService.selectSysShipList(sysShip);
    ExcelUtil<SysShip> util = new ExcelUtil<SysShip>(SysShip.class);
    util.exportExcel(response, list, "舰船参数数据");
  }

  /**
   * 获取舰船参数详细信息
   */
  @PreAuthorize("@ss.hasPermi('eddyAlgorithm:ship:query')")
  @GetMapping(value = "/{id}")
  public AjaxResult getInfo(@PathVariable("id") Integer id) {
    return success(sysShipService.selectSysShipById(id));
  }

  /**
   * 新增舰船参数
   */
  @PreAuthorize("@ss.hasPermi('eddyAlgorithm:ship:add')")
  @Log(title = "舰船参数", businessType = BusinessType.INSERT)
  @PostMapping
  public AjaxResult add(@RequestBody SysShip sysShip) {
    return toAjax(sysShipService.insertSysShip(sysShip));
  }

  /**
   * 修改舰船参数
   */
  @PreAuthorize("@ss.hasPermi('eddyAlgorithm:ship:edit')")
  @Log(title = "舰船参数", businessType = BusinessType.UPDATE)
  @PutMapping
  public AjaxResult edit(@RequestBody SysShip sysShip) {
    return toAjax(sysShipService.updateSysShip(sysShip));
  }

  /**
   * 删除舰船参数
   */
  @PreAuthorize("@ss.hasPermi('eddyAlgorithm:ship:remove')")
  @Log(title = "舰船参数", businessType = BusinessType.DELETE)
  @DeleteMapping("/{ids}")
  public AjaxResult remove(@PathVariable Integer[] ids) {
    return toAjax(sysShipService.deleteSysShipByIds(ids));
  }
}
